int do_fork(char* notUsed)
{
	int i;
	PROC* newProc, *procPnt = &procTable[runningProc->pid];
	
	for (i = 0; i < NUM_PROCS; i++)
		if (procTable[i].status == PROC_FREE)
			break;
			
	if (i == NUM_PROCS)
	{
		printf("Procedure table full, cannot fork!\n\n");
		return -1;
	}
	
	procTable[i].next = 0;
	procTable[i].parent = runningProc;
	procTable[i].sibling = 0;
	procTable[i].child = 0;
	procTable[i].status = PROC_READY;
	procTable[i].uid = runningProc->uid;
	procTable[i].gid = runningProc->gid;
	procTable[i].pid = i;
	procTable[i].ppid = runningProc->pid;
	procTable[i].cwd = runningProc->cwd;
	procTable[i].cwd->refCount++;
	
	procTable[procTable[i].parent->pid].child = &procTable[i];	
	newProc = &procTable[i];
	
	for (i = 0; i < NUM_FILE_DESC; i++)
		newProc->files[i] = procTable[newProc->ppid].files[i];
		
	while (procPnt->next != 0)
		procPnt = procPnt->next;
	procPnt->next = newProc;
	
	printf("P%d forked child process P%d\n\n", runningProc->pid, newProc->pid);
	return newProc->pid;
}
